<?php 
	$pid = Yii::app()->request->getParam("pid");
    $bid = Yii::app()->request->getParam("bid");
?>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/bug.css" />
<link rel='stylesheet' type='text/css' href="<?php echo Yii::app()->theme->baseUrl; ?>/css/jquery-ui-1.8.14.custom.css" />
<script type='text/javascript' src="<?php echo Yii::app()->theme->baseUrl; ?>/fullCalendar/jquery/jquery-ui-1.8.11.custom.min.js"></script>
<script type='text/javascript' src="<?php echo Yii::app()->theme->baseUrl; ?>/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	// load comment
	$(document).ready(function(){
		$("#comment-wrapper").load('<?php echo $this->createUrl('/comment/index',array('pid'=>$pid,'oid'=>$bid,'ctype'=>'BUG'))?>'	);
	});
	
    $(".popupCancel").click(function() {
            $.fancybox.close();
            });
    $("#bugHappenedDate").datepicker();
});
</script>
<div class="clear"></div>

			<div id="than">	
           	 	<img src="<?php echo Html::imageUrl("muiten.png");?>" width="27" height="26"; style="float:left">
            	<div id="textxanhdam">Messages </div>
		 	</div>
             <div class="padding15"></div>                    	
            	<!-- Begin leftSidebar -->                  
              	<div id="leftSidebar">
              		<div id="leftWrapper">
						<button type="button" id="addBugListButton" href="#addBugList">Add new bug list</button>
						<div class="padding20"></div>
						<h3>Bug Lists</h3>
						<ul>
						 <?php foreach($AllBugList as $item){?>
							<li><?php echo CHtml::link($item->bug_list_name,$this->createUrl('bugs/index',array('pid'=>$pid,'blid'=>$item->bug_list_id)));?></li>
							<?php } //end show allbug list?>
						</ul>
					</div>
				</div>
             	<!-- End leftSidebar -->
             	
                <!-- Begin rightSidebar -->
                <div id="rightSidebar">
                	<div id="rightHeader">
                		<h3><?php echo CHtml::encode($Bug->bug_name)?></h3>
                		by <?php echo CHtml::link(CHtml::encode($CreatedUser->user_name),"");?>
              
                		at <?php echo Html::formatDateTime($Bug->bug_happened_date,'Y-m-d h:m:s','D, d-M-Y h:m A');?>
                		
                		<div class="bdControl">
                			<a class="bdEditLink" href="#bdEdit">Edit</a>
                			<?php echo CHtml::link('Delete',$this->createUrl('/bugs/deletebug',
                			array('bid'=>$Bug->bug_id,'pid'=>$pid)),array('class'=>'bdDeleteLink'));?>
                			
                		</div>
                	</div>
                	<div id="rightWrapper">
                		<h3>Priority</h3>
                		<div id="bugDescription">
                		<?php switch($Bug->bug_priority){
                			case 1 : 
                				echo '<p class="bpHigh">High</p>';
                				break;
                			case 2 : 
                				echo '<p class="bpMedium">Medium</p>';
                				break;
                			case 3: 
                				echo '<p class="bpLow">Low</p>';
                				break;
                		}?>
                			
                		</div>
                		<div class="padding5"></div>
                		<h3>Problem description</h3>
                		<div id="bugDescription">
							<p><?php echo CHtml::encode($Bug->bug_description)?></p>
						</div>
						
						<div class="padding20"></div>
							<hr size="1px" type="solid" width="100%" color="#F1F1F1"></hr>
							<div class="padding20"></div>
							
						<div id="bdCommentWrapper">
							<div id="comment-wrapper">
									<!--  Load by jquery -->
							</div>
						</div>
                	</div>
                </div>
                <!-- End rightSidebar -->
                <a href="#"><img src="<?php echo Html::imageUrl("logonho.png");?>" width="145" height="48" border="0" style="float:right; margin-top:20px;"></a>
    </div>	
     <!-- Begin add bug list popup -->
	 <div id="addBLPopup" style="display: none;">
        <div id="addBugList" class="popupWrapper" action="" method="post">
                <div class="popupHeader">
                        <h2>New bug list</h2>
                </div>
                <div class="popupContent">
                        <h3>Bug list name</h3>
                        <div class="padding5"></div>
                        <?php 
                        $BugListForm= $this->beginWidget('CActiveForm',array(
                        'id'=>'bugList-form','enableAjaxValidation'=>false,));
                        echo $BugListForm->textField($NewBugList,'bug_list_name',array('class'=>'addBLName'));?>
                                <div class="padding10"></div>
                                <p>Description</p>
                        <?php 
                        echo $BugListForm->textArea($NewBugList,'bug_list_description',array(
                        'rows'=>4,'cols'=>70,));        
                        echo CHtml::submitButton('Create this bug list',array('class'=>'postButton'));
                        ?>
                                 or
                                        <a href="#" class="popupCancel">Cancel</a>
                                </div>
                        <?php  $this->endWidget();
                        
                        ?>
                        
                </div>
        </div>
        
        <!-- Begin edit bug detail -->
        <div id="bdEditPopup" style="display: none">
      
             
        	<div id="bdEdit" class="popupWrapper" action="" method="post">
        		<div class="popupHeader">
                        <h2>Edit bug</h2>
                </div>
                <div class="popupContent">
                	<h3>Bug name</h3>
                	<div class="padding5"></div>
                	<?php 
			          $BugEditForm = $this->beginWidget(
			          	'CActiveForm',array(
			          	'id'=>'bdEdit',
			            'enableAjaxValidation'=>false,
			            'action'=>$this->createUrl('/bugs/editbug',array('bid'=>$Bug->bug_id,'pid'=>$pid)),
			            
			          	)
			          );
			         ?>
			         <?php echo $BugEditForm->textField($Bug,'bug_name',array('value'=>$Bug->bug_name));?>
                		
                		<div class="padding10"></div>
                		<p>Priority</p> 
                		<?php 
                		$priority= array(1=>'High',2=>'Medium',3=>'Low');
                		echo $BugEditForm->dropDownList($Bug,'bug_priority',$priority,array('selected'=>$Bug->bug_priority));
                		?>
                        <div class="padding10"></div>
                        Bug Happened Date:
                        <?php 
                        $happenedDate=Html::formatDateTime($Bug->bug_happened_date, 'Y-m-d h:m:s','d/m/Y');
                        echo $BugEditForm->textField($Bug,'bug_happened_date',array('value'=>$happenedDate,
                        'id'=>'bugHappenedDate'));
                        ?>
                       
                        <div class="padding10"></div>
                        <p>Description</p>
                        <?php 
                        echo $BugEditForm->textArea($Bug,'bug_description',array('value'=>$Bug->bug_description,
                        'rows'=>4 ,'cols'=>70));
                        
                        ?>
                        <?php 
                        echo CHtml::submitButton('Save this bug',array('class'=>'postButton'));
                        ?>
                       or
                             <a href="#" class="popupCancel">Cancel</a>
                      
                	<?php $this->endWidget();?>
                </div>
        	</div>
        </div>
        <!-- End edit bug detail -->
    </div>
    <?php  $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'button#addBugListButton', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false,  'hideOnOverlayClick' =>false), ) ); ?>
    <?php  $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a.bdEditLink', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false,  'hideOnOverlayClick' =>false), ) ); ?>            